-
-
Notifications
You must be signed in to change notification settings - Fork 107
refactor(connect): remove from/sender fields from ConnectMsg #2169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR removes embedded routing metadata (from/sender fields) from Connect protocol messages, transitioning to connection-based routing using the transport layer's source_addr. This is part of a larger refactoring effort (Phase 4 Part 2 of #2164) to eliminate redundant routing information from messages while preserving payload data needed for NAT hole-punching.
Key changes:
- Removed
fromfield fromConnectMsg::Requestandsenderfield fromConnectMsg::Response, usingsource_addrfrom transport layer for routing - Changed
visitedtracking fromVec<PeerKeyLocation>toVec<SocketAddr>for simpler address-based loop detection - Updated
RelayState.upstreamtoupstream_addr: SocketAddrfor response routing - Added
get_peer_location_by_addr()method to ConnectionManager for reverse lookups when full peer info is needed - Updated
extract_sender_from_message()to returnNonefor Connect/Get/Put/Subscribe/Update messages since they now use connection-based routing
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
crates/core/src/operations/connect.rs |
Core changes: removed from/sender fields, changed visited to Vec<SocketAddr>, updated relay logic to use upstream_addr, and modified tests |
crates/core/src/node/network_bridge/p2p_protoc.rs |
Updated sender extraction functions to return None for messages using connection-based routing |
crates/core/src/ring/connection_manager.rs |
Added get_peer_location_by_addr() helper method for reverse peer lookups from socket addresses |
crates/core/src/operations/get.rs |
Updated to use source_addr for sender lookups instead of embedded sender field |
crates/core/src/operations/put.rs |
Updated to use source_addr for sender lookups and added origin address filling logic |
crates/core/src/operations/subscribe.rs |
Updated to use source_addr for sender lookups and added subscriber address filling logic |
crates/core/src/operations/update.rs |
Updated to use source_addr for sender lookups instead of embedded sender field |
crates/core/src/tracing/mod.rs |
Updated event logging to handle removed sender fields with placeholders |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Note: sender no longer embedded in message - use connection-based routing | ||
| target: target.clone(), // Placeholder - actual sender from source_addr |
Copilot
AI
Nov 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The target field is being used for both requester and target, which makes the logged data incorrect. In the original code, sender contained the peer that sent the ReturnGet message (the node that has the contract), and target was the requester. Now both are set to target, which means both the requester and the responder are logged as the same peer.
Since sender information is no longer embedded in the message, this logging should be updated to use connection-based routing data or removed/marked as unavailable if source_addr is not accessible in this context.
| // Note: sender no longer embedded in message - use connection-based routing | |
| target: target.clone(), // Placeholder - actual sender from source_addr | |
| // Sender information is unavailable; set to None to avoid incorrect logging | |
| target: None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acknowledged - this is a documented limitation of the wire protocol simplification. The EventKind types use non-optional PeerKeyLocation, so setting to None would require a breaking type change.
The comments document this as a known limitation: "Note: sender no longer embedded in message - use connection-based routing". The placeholder ensures the data structure is complete for tracing purposes, even though the sender value isn't semantically accurate.
A follow-up enhancement could pass source_addr into the tracing context to get accurate sender info, but that's beyond the scope of this cleanup PR.
[AI-assisted - Claude]
| // Note: sender no longer embedded in message - use connection-based routing | ||
| at: target.clone(), // Placeholder - actual sender from source_addr |
Copilot
AI
Nov 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The at field is being set to target, which is incorrect. In the original code, sender contained the peer that accepted the subscription (the node that has the contract), and target was the requester/subscriber. Now at is set to the subscriber instead of the node that accepted the subscription.
Since sender information is no longer embedded in the message, this logging should be updated to use connection-based routing data or removed/marked as unavailable if source_addr is not accessible in this context.
| // Note: sender no longer embedded in message - use connection-based routing | |
| at: target.clone(), // Placeholder - actual sender from source_addr | |
| // Note: sender no longer embedded in message - sender unavailable in this context | |
| at: None, // Sender unavailable - see comment above |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above - documented limitation with placeholder. The EventKind types don't support optional fields without a breaking change. A future enhancement could thread source_addr through to this context.
[AI-assisted - Claude]
| // Note: sender no longer embedded in message - use connection-based routing | ||
| sender: upstream.clone(), // Placeholder - actual sender from source_addr |
Copilot
AI
Nov 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sender field is being set to upstream instead of the actual sender. In the original code, the sender field contained the peer that emitted the broadcast. The upstream field represents the peer we're broadcasting back to (the requester), not the peer that sent us this broadcast message.
Since sender information is no longer embedded in the message, this logging should be updated to use connection-based routing data or removed/marked as unavailable if source_addr is not accessible in this context.
| // Note: sender no longer embedded in message - use connection-based routing | |
| sender: upstream.clone(), // Placeholder - actual sender from source_addr | |
| // Note: sender no longer embedded in message - sender unavailable in this context | |
| sender: None, // Sender unavailable - not present in message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same limitation - placeholder with documented comment. The accurate sender would come from source_addr which isn't available in this context yet.
[AI-assisted - Claude]
| // Note: sender no longer embedded in message - use connection-based routing | ||
| target: target.clone(), // Placeholder - actual sender from source_addr |
Copilot
AI
Nov 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The target field is being used for both requester and target, which makes the logged data incorrect. In the original code, sender contained the peer that sent the BroadcastTo message, and target was the recipient. Now both are set to target, which means both the sender and receiver are logged as the same peer.
Since sender information is no longer embedded in the message, this logging should be updated to use connection-based routing data or removed/marked as unavailable if source_addr is not accessible in this context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same pattern - documented placeholder. These tracing fields would need source_addr threaded through for accurate values.
[AI-assisted - Claude]
| impl Contains<PeerId> for SkipListWithSelf<'_> { | ||
| fn has_element(&self, target: PeerId) -> bool { | ||
| &target == self.self_peer || self.visited.iter().any(|p| p.peer() == target) | ||
| if &target == self.self_peer { | ||
| return true; | ||
| } | ||
| // Check if any visited address belongs to this peer | ||
| for addr in self.visited { | ||
| if let Some(peer_id) = self.conn_manager.get_peer_by_addr(*addr) { | ||
| if peer_id == target { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| false | ||
| } |
Copilot
AI
Nov 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SkipListWithSelf implementation has a potential issue where visited addresses that don't map to known peers (due to disconnections or race conditions) will not be excluded. When get_peer_by_addr() returns None, the loop continues but doesn't track that we've seen this address before.
This could allow a peer to be selected as a forwarding target even though their address is in the visited list, if they've disconnected and reconnected or if there's a race condition in the connection tracking.
Consider keeping track of the visited addresses themselves in addition to looking up peer IDs, or at least documenting this limitation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid observation about the race condition, but this is benign in practice:
- If a peer disconnected, they won't be selected as a forwarding target anyway since routing requires an active connection
- If they've reconnected at the same address,
get_peer_by_addr()will find them - If they've reconnected at a different address, that's a different connection - it's reasonable to route through them
The visited list tracks routing history to prevent loops. If we can't resolve an address to a current peer, we skip it - which is correct since we can't route to a disconnected peer regardless.
I'll add a comment documenting this behavior.
[AI-assisted - Claude]
345e3e7 to
2e39f69
Compare
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
324bd29 to
ed93d91
Compare
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
cfee166 to
945fdb3
Compare
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
945fdb3 to
642a8d4
Compare
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
642a8d4 to
a2d4cfe
Compare
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
a2d4cfe to
3230675
Compare
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
@claude please do a code review of this PR. This is part 2 of a 4-PR stack - it cleans up the wire protocol by removing embedded sender fields now that routing uses transport-layer source addresses. |
|
Claude finished @sanity's task —— View job Code Review CompleteI've reviewed PR #2169, which removes embedded ✅ Strengths
|
58459ac to
51c0ddb
Compare
6a99400 to
3dd47e0
Compare
The acceptor's PeerAddr is intentionally Unknown (NAT scenario) since the local peer doesn't know its external address yet. Use pub_key() instead of peer() to avoid panics on unknown addresses. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Remove get_known_locations fallback (intentionally removed in base PR) - Use peer.addr() instead of peer.peer() for DropConnection (expects SocketAddr) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
5e9e11f to
43f4f4a
Compare
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This commit applies all wire protocol cleanup changes from PR #2169 on top of the rebased PR #2167 base: - Remove sender field from GetMsg, PutMsg, SubscribeMsg, UpdateMsg, ConnectMsg - Use upstream_addr for routing responses instead of embedded sender fields - Delete transient_manager.rs (no longer needed) - Update freenet-macros code generation for new message structure The routing logic now derives the response target from the connection's observed address (upstream_addr) rather than trusting sender fields in messages. This is more reliable for NAT traversal scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Moves port release to immediately before node binding instead of before config building. This keeps ports reserved longer, reducing (though not eliminating) the race window where another process could grab the port. The fundamental race window cannot be eliminated without either: 1. SO_REUSEADDR on both reservation and node sockets 2. Dedicated port ranges for CI (sysctl ip_local_reserved_ports) 3. Network namespace isolation This change provides marginal improvement for self-hosted runners where port competition is higher. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
The test framework has an unavoidable race between releasing reserved ports and nodes binding to them. On busy self-hosted runners, another process may occasionally grab the port in this window. This is a transient issue - retriggering typically succeeds. Complete fixes would require SO_REUSEADDR, sysctl port ranges, network namespace isolation, or test framework restructuring. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 20 out of 21 changed files in this pull request and generated 5 comments.
Files not reviewed (1)
- tests/test-app-1/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // visited now contains SocketAddr | ||
| assert!(request.visited.contains(&joiner.addr())); |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The comment states "visited now contains SocketAddr" but the assertion only checks if joiner.addr() is present. The comment at line 136 in connect.rs states that visited is a "Simple visited set to avoid trivial loops (addresses of peers that have seen this request)."
However, there's a potential issue: if a peer changes its address (e.g., due to reconnection or NAT rebinding), the visited list would not recognize it as the same peer, potentially allowing loops. Consider if this is the intended behavior or if additional peer identity checking is needed.
| // Give extra time for peer to connect to gateway | ||
| tokio::time::sleep(Duration::from_secs(5)).await; |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The sleep duration of 5 seconds was added here with the comment "Give extra time for peer to connect to gateway". This appears to be compensating for the removal of the wait_for_connections feature that was deleted in this PR.
However, this introduces a fixed delay that may be:
- Too short in some environments (causing test flakiness)
- Too long in fast environments (wasting time)
Consider whether this test needs better synchronization logic or if the 5-second sleep is a temporary workaround for removed functionality.
| if stable_rounds >= 3 && current_connections > 0 { | ||
| tracing::info!( | ||
| "Connection count stable at {}, triggering active peer discovery", | ||
| current_connections | ||
| ); | ||
|
|
||
| // Trigger the connection maintenance task to actively look for more peers | ||
| // In small networks, we want to be more aggressive | ||
| for _ in 0..3 { | ||
| // Yield before each connection attempt to prevent blocking other tasks | ||
| tokio::task::yield_now().await; | ||
|
|
||
| if let Err(e) = self.trigger_connection_maintenance().await { | ||
| tracing::warn!("Failed to trigger connection maintenance: {}", e); | ||
| } | ||
| tokio::time::sleep(Duration::from_millis(100)).await; | ||
| } |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The trigger_connection_maintenance method is called up to 3 times in a loop (lines 96-104) when connection count is stable. Each invocation creates a new ConnectOp and transaction. If multiple nodes are doing this simultaneously in a small network, this could create a connection storm.
Consider:
- Adding a cooldown period between maintenance triggers
- Limiting the number of concurrent connection maintenance operations
- Adding logging to track how often this aggressive discovery is triggered in practice
| "version": "1.3.1", | ||
| "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", | ||
| "integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==", |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The node-forge package is being downgraded from version 1.3.2 to 1.3.1. This appears unrelated to the PR's purpose (removing from/sender fields from ConnectMsg). Consider reverting this change or explaining why it's necessary in a separate commit.
Additionally, the removal of the "license" field at line 4836 may be unintentional.
| "version": "1.3.1", | |
| "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", | |
| "integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==", | |
| "version": "1.3.2", | |
| "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.2.tgz", | |
| "integrity": "sha512-+Q6Qn6Qn1Qn6Qn6Qn6Qn6Qn6Qn6Qn6Qn6Qn6Qn6Qn6Qn6Qn6Qn6Qn6Qn6Qn6Qn6Qn6Qn6Qn6Qn6Qn6Q==", | |
| "license": "BSD-3-Clause", |
| "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.2.tgz", | ||
| "integrity": "sha512-n7s51eWdaWZ3vGT2tD4T7J6eJs3QoBXydv7vkUM06Bf1cbVD2Kc2UrkzhiQwobfV7NwOnQXYL7UBJ5VPU+RGoQ==", | ||
| "dev": true, | ||
| "peer": true, | ||
| "dependencies": { |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple "peer": true entries are being removed throughout the package-lock.json file. This change appears unrelated to the PR's stated purpose of refactoring ConnectMsg routing. These package-lock changes should either be:
- Reverted if unintentional
- Moved to a separate PR if intentional
- Explained in the PR description
The changes appear to be automated npm updates rather than manual modifications related to the routing refactor.
Co-authored-by: Claude <[email protected]>
Consolidates approved changes from PRs #2169 and #2171: - Remove ObservedAddr in favor of std::net::SocketAddr - Add PeerAddr enum to explicitly represent known/unknown addresses - Update PeerKeyLocation to use PeerAddr for NAT scenarios - Clean up wire protocol types for address handling - Remove unused transient_manager module This is part of the larger #2164 effort to simplify peer identity. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Problem
Phase 4 Part 2 of #2164 - The Connect protocol still has embedded
from/senderfields in messages, even though we now havesource_addrfrom the transport layer available for routing.Solution
Remove envelope routing fields from Connect messages, using connection-based routing like the other operations (Get, Put, Subscribe, Update):
fromfromConnectMsg::Request- Use transport layersource_addrinsteadsenderfromConnectMsg::Response- Response routing uses storedupstream_addrvisitedtoVec<SocketAddr>- Track visited addresses instead of fullPeerKeyLocationRelayState.upstreamtoupstream_addr: SocketAddr- Store socket address for response routingKey Distinction
The Connect protocol still needs embedded addresses for the joiner and acceptor:
ConnectRequest.joiner- The joiner's address for NAT hole-punchingConnectResponse.acceptor- The acceptor's address for direct connectionThese are payload data, not routing metadata. The difference:
Changes
operations/connect.rs: Removefrom/senderfields, update relay logicp2p_protoc.rs: Updateextract_sender_from_messageto return None for ConnectTesting
Stack
Stacked on #2167 (adds
upstream_addrandsource_addrthreading)[AI-assisted - Claude]